<template>
  <div class="volunteer-certificate">
    <!-- 证书信息卡片 -->
    <el-card class="certificate-card">
      <div class="certificate-header">
        <img src="/images/logo.png" alt="Logo" class="logo">
        <h2>志愿者证书</h2>
      </div>
      
      <div class="certificate-content">
        <div class="info-row">
          <div class="info-item">
            <span class="label">证书编号：</span>
            <span class="value">VOL-2024-001</span>
          </div>
          <div class="info-item">
            <span class="label">发证日期：</span>
            <span class="value">2024-01-15</span>
          </div>
        </div>

        <div class="volunteer-info">
          <el-avatar :size="80" :src="volunteerAvatar" />
          <div class="info-list">
            <div class="info-item">
              <span class="label">姓名：</span>
              <span class="value">张三</span>
            </div>
            <div class="info-item">
              <span class="label">志愿者ID：</span>
              <span class="value">V20240115001</span>
            </div>
            <div class="info-item">
              <span class="label">加入时间：</span>
              <span class="value">2024-01-15</span>
            </div>
            <div class="info-item">
              <span class="label">志愿时长：</span>
              <span class="value highlight">48小时</span>
            </div>
          </div>
        </div>

        <div class="qr-code">
          <el-image src="/images/qr-code.png" :width="100" :height="100" />
          <p>扫码验证证书</p>
        </div>
      </div>

      <div class="certificate-footer">
        <p>本证书由海洋生态保护志愿者协会授予</p>
        <img src="/images/seal.png" alt="Official Seal" class="seal">
      </div>
    </el-card>

    <!-- 志愿记录 -->
    <el-card class="records-card">
      <template #header>
        <div class="card-header">
          <h3>志愿服务记录</h3>
          <el-button type="primary" plain>导出记录</el-button>
        </div>
      </template>

      <el-table :data="serviceRecords" stripe>
        <el-table-column prop="date" label="日期" width="120" />
        <el-table-column prop="project" label="项目名称" />
        <el-table-column prop="location" label="地点" width="150" />
        <el-table-column prop="hours" label="服务时长" width="100">
          <template #default="scope">
            {{ scope.row.hours }} 小时
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag :type="scope.row.status === '已认证' ? 'success' : 'warning'">
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>
      </el-table>

      <div class="pagination">
        <el-pagination
          v-model:current-page="currentPage"
          :page-size="10"
          :total="100"
          background
          layout="prev, pager, next"
        />
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const currentPage = ref(1)
const volunteerAvatar = ref('https://placeholder.com/150')

const serviceRecords = ref([
  {
    date: '2024-03-15',
    project: '海滩清理活动',
    location: '深圳湾海滩',
    hours: 4,
    status: '已认证'
  },
  {
    date: '2024-03-10',
    project: '珊瑚保护宣传',
    location: '海洋公园',
    hours: 6,
    status: '已认证'
  },
  {
    date: '2024-03-05',
    project: '海洋生态调研',
    location: '大鹏新区',
    hours: 8,
    status: '待认证'
  }
])
</script>

<style scoped lang="scss">
.volunteer-certificate {
  .certificate-card {
    margin-bottom: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    
    .certificate-header {
      text-align: center;
      margin-bottom: 30px;
      
      .logo {
        width: 80px;
        height: 80px;
        margin-bottom: 15px;
      }

      h2 {
        margin: 0;
        color: #303133;
        font-size: 24px;
      }
    }

    .certificate-content {
      padding: 20px 40px;
      border: 2px solid #ebeef5;
      border-radius: 8px;
      position: relative;
      background: #fff;

      .info-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;
      }

      .volunteer-info {
        display: flex;
        gap: 30px;
        margin-bottom: 30px;

        .info-list {
          flex: 1;
        }
      }

      .info-item {
        margin-bottom: 15px;
        
        .label {
          color: #909399;
          margin-right: 10px;
        }

        .value {
          color: #303133;
          font-weight: 500;

          &.highlight {
            color: #409EFF;
            font-size: 16px;
          }
        }
      }

      .qr-code {
        position: absolute;
        right: 40px;
        bottom: 40px;
        text-align: center;

        p {
          margin: 10px 0 0;
          font-size: 12px;
          color: #909399;
        }
      }
    }

    .certificate-footer {
      text-align: center;
      margin-top: 30px;
      position: relative;

      p {
        color: #606266;
        margin: 0;
      }

      .seal {
        position: absolute;
        right: 60px;
        top: 50%;
        transform: translateY(-50%);
        width: 100px;
        opacity: 0.8;
      }
    }
  }

  .records-card {
    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;

      h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
      }
    }

    .pagination {
      margin-top: 20px;
      text-align: right;
    }
  }
}
</style> 